package com.xiaoshuidi.cloud.module.member.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum WriteOffStatusEnum {
    TO_BE_WRITTEN_OFF(1,"待核销"),
    WRITTEN_OFF(2,"已核销"),
    EXPIRED(3,"已失效");
    private Integer code;
    private String name;

    public static String getNameByCode(Integer code) {
        WriteOffStatusEnum writeOffStatusEnum = Arrays.stream(WriteOffStatusEnum.values()).filter(p -> p.code.intValue() == code.intValue()).findFirst().orElse(null);
        Assert.isTrue(writeOffStatusEnum != null, "WriteOffStatusEnum:{}不存在", code);
        return writeOffStatusEnum.getName();
    }
}
